package cn.highedu.coolshark_product.controller;

import cn.highedu.coolshark_product.pojo.entity.User;
import io.swagger.annotations.*;
import org.apache.ibatis.annotations.Update;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

/**
 * 测试Swagger
 */
@RestController
@RequestMapping("/users")
@Api(tags = "用户管理") // 描述API信息
public class UserController {
    @ApiOperation(value = "获取用户信息", notes = "根据用户ID获取用户信息")
    @GetMapping("/{id}")
    public User getUserById(@PathVariable Integer id) {
        return null;
    }

    @ApiOperation(value = "更新用户信息", notes = "根据用户ID更新用户信息")
    @PutMapping("/update")
    public JsonResult<Void> update(@ApiParam("用户信息") @RequestBody User user) {
        return null;
    }

    @ApiOperation(value = "删除用户信息", notes = "根据用户ID删除用户信息")
    @ApiResponses({ // 描述响应信息, 是一个数组
            @ApiResponse(code = 200, message = "删除成功"), // 描述具体的响应状态
            @ApiResponse(code = 404, message = "用户不存在")
    })
    @DeleteMapping("/{id}")
    public JsonResult<Void> delete(@PathVariable Integer id) {
        return null;
    }

    @ApiIgnore // 屏蔽某个操作 不在文档中显示
    @GetMapping("/list")
    public JsonResult<List<User>> list() {
        return null;
    }

    @ApiOperation(value = "分页查询", notes = "分页查询所有用户信息")
    @ApiImplicitParams({
            // 声明的参数必须使用@RequestParam注解修饰(参数不可省略)
            @ApiImplicitParam(name = "pageIndex", value = "页码", defaultValue = "1", dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "size", value = "每页数量", defaultValue = "10", dataType = "int", paramType = "query")
    })
    @GetMapping("/")
    public JsonResult<List<User>> getUsers(@RequestParam(defaultValue = "1") int pageIndex,
            @RequestParam(defaultValue = "10") int size) {
        return null;
    }
}
